package com.seecen.controller;

import com.seecen.pojo.Order;
import com.seecen.service.OrderService;
import com.seecen.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
@CrossOrigin
public class OrderController {


    @Autowired
    private OrderService orderService;

    //创建订单
    @PostMapping("createOrder")
    private Result createOrder(@RequestBody Order order){
         Result ret = orderService.createOrder(order);
         return ret;
    }

    // 根据用户id查询用户订单
    @PostMapping("listOrdersById")
    private  Result listOrdersById( @RequestParam("userId") Integer userId){
        Result ret = orderService.listOrdersById(userId);
        return ret;
    }


    // 支付订单
    @PostMapping("payOrder")
    private Result payOrder(@RequestParam("orderId") Integer orderId){
        Result ret = orderService.payOrder(orderId);
        return  ret;
    }

}
